#ifndef WRAP_TIMERFD_H
#define WRAP_TIMERFD_H

struct itimerspec;

namespace Wrap {

int tfd_nonblock();
int tfd_cloexec();

/// @see https://man7.org/linux/man-pages/man2/timerfd_create.2.html
/// @return On success, timerfd_create() returns a new file descriptor. On
/// error, -1 is returned and errno is set to indicate the error.
/// @throw EINVAL The @c clock_id is not valid.
/// @throw EINVAL @c flags is invalid; or, in Linux 2.6.26 or earlier, @c flags
/// is nonzero.
/// @throw EMFILE The per-process limit on the number of open file descriptors
/// has been reached.
/// @throw ENFILE The system-wide limit on the total number of open files has
/// been reached.
/// @throw ENODEV Could not mount (internal) anonymous inode device.
/// @throw ENOMEM There was insufficient kernel memory to create the timer.
/// @throw EPERM @c clock_id was CLOCK_REALTIME_ALARM or CLOCK_BOOTTIME_ALARM
/// but the caller did not have the CAP_WAKE_ALARM capability.
int timerfd_create_(int clock_id, int flags);

/// @see https://man7.org/linux/man-pages/man2/timerfd_create.2.html
/// @return timerfd_settime() return 0 on success; on error they return -1, and
/// set errno to indicate the error.
/// @throw EBADF @c ufd is not a valid file descriptor.
/// @throw EFAULT @c utmr, or @c otmr is not valid a pointer.
/// @throw EINVAL @c ufd is not a valid timerfd file descriptor.
/// @throw ECANCELED See NOTES.
/// @throw EINVAL @c utmr is not properly initialized (one of the tv_nsec falls
/// outside the range zero to 999,999,999).
/// @throw EINVAL @c flags is invalid.
int timerfd_settime_(
    int ufd, int flags, const struct itimerspec *utmr, struct itimerspec *otmr);

}


#endif